﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class GUI_Pages_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void parents_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("http://www.cairositters.com/GUI/Pages/ParentRegistration1.aspx");
    }
    protected void sitters_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("http://www.cairositters.com/GUI/Pages/BabysitterRegistration1.aspx");
    }
    protected void fbButton_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("https://www.facebook.com/CairoSitters");
    }
    protected void twitButton_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("https://twitter.com/#!/CairoSitters");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string username = TextBox4.Text;
        string password = TextBox5.Text;

        string connStr = ConfigurationManager.ConnectionStrings["CSConn"].ToString();
        SqlConnection conn = new SqlConnection(connStr);

        SqlCommand cmd1 = new SqlCommand("SELECT a.AccountID, a.AccountTypeID FROM AccountTypes at " + 
            "INNER JOIN Accounts a ON at.AccountTypeID = a.AccountTypeID " + 
            "WHERE a.UserName = @username AND a.Pass_word = @password", conn);
        cmd1.CommandType = CommandType.Text;
        cmd1.Parameters.Add(new SqlParameter("@username", username));
        cmd1.Parameters.Add(new SqlParameter("@password", password));

        conn.Open();
        cmd1.ExecuteNonQuery();
        conn.Close();

        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd1);
        da.Fill(dt);
   
        if (dt.Rows.Count == 0)
        {
            Label1.Visible = true;
        }
        else
        {
            int x = dt.Rows[0].Field<int>(1);
            if (x == 3)
            {
               // Session["acctID"] = dt.Rows[0].Field<int>(0);
                Response.Redirect("http://www.cairositters.com/GUI/Pages/Admin.aspx");
            }
        }

    }
}
